* New unit test directory
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Tue, 3 Jan 2006 05:25:29 +0000 (05:25 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Tue, 3 Jan 2006 05:25:29 +0000 (05:25 +0000)
maintenance/tests/ctype.php [new file with mode: 0644]

diff --git a/maintenance/tests/ctype.php b/maintenance/tests/ctype.php
new file mode 100644 (file)
index 0000000..df7cf36
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+define( 'MEDIAWIKI', true );
+$cont = file_get_contents( '../../includes/compatability/ctype.php' );
+$cont = preg_replace( '~^<\?php~', '', $cont );
+preg_match_all( '~function (ctype_[a-z]+)~', $cont, $m );
+$cont = preg_replace( '~(function )(ctype_)~', '\1_\2', $cont );
+$cont = preg_replace( '~\?>$~', '', $cont );
+
+eval( $cont );
+
+foreach ( $m[1] as $function ) {
+       $php = "$function";
+       $mw = "_$function";
+       $range = range( -1000, 1000 );
+       foreach ( $range as $i ) {
+               ret_cmp( $php, $i, $php( $i ), $mw( $i ) );
+       }
+
+       foreach ( $range as $i ) {
+               $i = chr( $i );
+               ret_cmp( $php, $i, $php( $i ), $mw( $i ) );
+       }
+
+       ret_cmp( $php, $i, $php( array() ), $mw( array() ) );
+}
+
+function ret_cmp( $fname, $in, $php, $mw ) {
+       if ( $php != '' )
+               return;
+       if ( $php !== $mw )
+               echo "PHP $fname() returned '" . serialize( $php ) . "' for '" . serialize( $in) . "', MediaWiki returned '" . serialize( $mw ) . "'\n";
+}
+?>